import { RectNode, RectNodeModel } from '@logicflow/core';


export const startNode = {
 id: 'start',
 type: 'circle',
 x: 100,
 y: 250,
 text: {
  x: 100,
  y: 250,
  value: 'start'
 },
 properties: {
  style: {
   fill: '#f0f0f0',
   stroke: '#000',
  },
 },
}

// 结果节点
export const resultNode = {
 id: 'result',
 type: 'custom-rect',
 x: 1000,
 y: 250,
 backgroundColor: '#409EFF',
 text: {
  x: 1000,
  y: 250,
  value: 'result'
 },
 properties: {
  backgroundColor: '#409EFF',
  style: {
   fill: '#ffffff',
   stroke: '#000',
   backgroundColor: '#409EFF',

  },
 },
};

// 自定义节点
class CustomRectNode extends RectNode { }

class CustomRectModel extends RectNodeModel {
 // 设置矩形的形状属性：大小和圆角
 setAttributes() {
  const { width = 150, height = 60, radius = 10 } = this.properties
  this.width = width;
  this.height = height;
  this.radius = radius;
  
 }
 
 // 重写文本样式属性
 // getTextStyle(){
 //   const { refX = 0, refY = 0 } = this.properties 
 //   const style = super.getTextStyle();

 //   // 通过 transform 重新设置 text 的位置：向下移动70px
 //   return {
 //     ...style,
 //     // transform: `matrix(1 0 0 1 ${refX} ${refY})`,
 //     // transform: `matrix(1 0 0 1 ${refX} ${refY + 60})`,
 //   };
 // }

 // 设置矩形的样式属性：边框颜色
 // getNodeStyle() {
 //   const style = super.getNodeStyle();
 //   // style.stroke = 'blue';
 //   return style;
 // }
}

export default {
 type: 'custom-rect',
 view: CustomRectNode,
 model: CustomRectModel,
};